#include <iostream>
#include <map>
#include <vector>

using namespace std;

struct segment {
	int a, b;	
};

struct point {
	int x, y;
	int d[4];
	point() {
		for (int i = 0; i < 4; i++) d[i] = 0;
	}
};

struct pair_int {
	int x, y;
	pair_int(int a, int b) { 
		x = a; 
		y = b; 
	}

	bool operator() (int x, int y) {
		return x < y;
	}
};

point p[100000];
segment s[100000];
bool ok[100000];
bool found;
vector<int> result;
map<pair_int, int> mB;

int n, w, w_left;

void swap(int* x, int* y)
{
	int temp = *x;
	*x = *y;
	*y = temp;
}

void findLeftMost(int *xx, int *yy, int *ss)
{
}

void mark(int xx, int yy, int ss)
{
	mB[pair_int(xx, yy)] = ss;
	ok[ss] = false;
}

int isMarked(int xx, int yy)
{
	if (mB.find(pair_int(xx, yy)) == mB.end()) reurn 0;
	return mB[pair_int(xx, yy)];
}

void traverse(int start, int xx, int yy, int ss)
{
	if (found) return;

	mark(xx, yy, ss);

	int p = isMarked(yy, xx);

	if (p != 0) result.push_back(p);

	if (yy == start)
	{
		found = true;
		return;
	}
	
	for (int i = 0; i < 4; i++)
		if (p[yy].d[i] != 0)
		{
			int ss = p[yy].d[i];
			if (s[ss].a == yy) traverse(start, yy, s[ss].b, ss);
			else traverse(start, yy, s[ss].a, ss);
		}
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) cin >> p[i].x >> p[i].y;

	cin >> w;
	for (int i = 0; i < w; i++)
	{
		cin >> s[i].a >> s[i].b;
		if (s[i].a > s[i].b) swap(&s[i].a, &s[i].b);

		if (p[s[i].a].x == p[s[i].b].x)
		{
			if (p[s[i].a].y < p[s[i].b].y)
			{
			}
			else
			{
			}
		}
		else
		{
		}
	}

	memset(ok, true, sizeof(ok));

	result.clear();

	w_left = w;
	while (w_left != 0)
	{
		int xx, yy, ss;
		findLeftMost(&xx, &yy, &ss);
		traverse(xx, xx, yy, ss);
	}	

	for (int i = 0; i < result.size(); i++) cout << result[i] << endl;
	return 0;
}
